import matplotlib.pyplot as plt
import pandas as pd
df = pd.read_excel('学生各学期成绩表.xlsx')
plt.figure(figsize=(10, 8))
x = df['序号']
y = df['语文']
m = df['数学']
n = df['英语']
z = df['综合']
plt.rcParams['font.sans-serif'] = 'SimHei'
plt.title('学生各学期成绩分析')
plt.xlabel('学期')
plt.ylabel('成绩')


plt.subplot(2,2,1)
plt.plot(x, y,'--^')
plt.grid(axis='both')
plt.legend(('语文',))
for a, b in zip(df['序号'], df['语文']):
    plt.text(a, b, '%.1f' % b, ha='center')
plt.xticks(range(11))

plt.subplot(2,2,2)
plt.plot(x, m,'c-.*')
plt.grid(axis='y')
plt.legend(('数学',))
for a, b in zip(df['序号'], df['数学']):
    plt.text(a, b, '%.1f' % b, ha='center')
plt.xticks(range(11))

plt.subplot(2,2,3)
plt.plot(x, n,'g-.o')
plt.grid(axis='x')
plt.legend(('英语',))
for a, b in zip(df['序号'], df['英语']):
    plt.text(a, b, '%.1f' % b, ha='center')
plt.xticks(range(11))

plt.subplot(2,2,4)
plt.plot(x, z,'r:d')
plt.legend(('综合',))
for a, b in zip(df['序号'], df['综合']):
    plt.text(a, b, '%.1f' % b, ha='center')
plt.xticks(range(11))
plt.show()